<template>
    <div class="login-container">
        <el-form ref="ruleFormRef" style="max-width: 400px" :model="login" status-icon label-width="auto"
            class="demo-ruleForm">
            <el-form-item label="用户名" prop="pass">
                <el-input v-model="login.userName" />
            </el-form-item>
            <el-form-item label="密码" prop="checkPass">
                <el-input v-model="login.userPass" type="password" show-password />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="loginsub">
                    登录
                </el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { Read } from '@/Http/Axios'
import router from '@/router'
import { useCounterStore } from '@/stores/counter'

const store = useCounterStore()

const login = reactive({
    userName: "",
    userPass: ""
})

const loginsub = () => {
    Read.post("/Login", login).then(res => {
        if (res.data.code == 500) {
            ElMessage.success("登陆成功");
            store.account.UserName = res.data.data.userName
            store.account.UserNickName = res.data.data.userNickName
            router.push("/IndexView")
        } else {
            ElMessage.error("登陆失败");
        }
    })
}
</script>

<style scoped>
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.demo-ruleForm {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 400px;
    transition: transform 0.3s ease;
}

.demo-ruleForm .el-form-item__label {
    font-size: 15px;
    color: #333;
    font-weight: 500;
}

.demo-ruleForm .el-input__wrapper {
    height: 44px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s ease;
}

.demo-ruleForm .el-input__wrapper:hover {
    border-color: #4facfe;
}

.demo-ruleForm .el-button {
    width: 100%;
    height: 44px;
    font-size: 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    border: none;
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
}

.demo-ruleForm .el-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.demo-ruleForm .el-form-item {
    margin-bottom: 20px;
}
</style>

<style>
html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* background: linear-gradient(135deg, #ff9a9e 0%, #f6d365 100%); */
    /* 渐变黄昏色 */
}

#app {
    height: 100%;
}
</style>